<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function varTest() {
                var x = 1;
                {
                    var x = 2; // same variable!
                    console.log(x); // 2
                }
                console.log(x); // 2
            }
            varTest();

            function letTest() {
                let x = 1;
                {
                    let x = 2; // different variable
                    console.log(x); // 2
                }
                console.log(x); // 1
            }
            letTest();
    </script>
</head>
<body>
    
</body>
</html>